<template>
  <div class="bottom-menu-wrap">
    <div class="dis-cen menu-par">
      <div v-for="(val,index) in menu" :key="index" class="dis-cen menu-one">
        <span>{{ val.name }}</span>
        <div class="dis-cen menu-icon">
          <img src="@/assets/icon/jianche.png" alt="实时检测">
        </div>
        <div class="child-menu-wrap">
          <p
            v-for="(childVal,index2) in val.children"
            :key="index2"
            class="dis-start child-menu-one"
            @click.stop="goMenu(childVal)"
          >
            <img src="@/assets/icon/record-report.png" alt>
            <span>{{ childVal.name }}</span>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BottomMenu',
  data() {
    return {
    }
  },
  computed: {
    menu() {
      return this.$store.state.user.permissionsTree.children
    }
  },
  methods: {
    goMenu(val) {
      const component = val.component
      if (component) {
        this.$store.dispatch('window/addTabItem', {
          title: val.name,
          component: component,
          data: {
            test: ''
          }
        })
      } else {
        this.$message({
          message: '找不到对应菜单',
          type: 'error'
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import "@/styles/com.scss";
@import "@/styles/variables.scss";
.bottom-menu-wrap {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
}
.menu-par {
  width: 100%;
  height: 100%;
  .menu-one {
    position: relative;
    flex-direction: column;
    padding: 10px;
    margin: 0 5px;
    white-space: nowrap;
    background: $nodeLightBk;
    cursor: pointer;
    & > span {
      font-size: 17px;
      color: #fff;
    }
    &:hover {
      & > span {
        color: $daihoverColor;
      }
      & .menu-icon {
        background: #1c5252;
      }
      & .child-menu-wrap {
        display: block;
        opacity: 1;
      }
    }
    .menu-icon {
      width: 60px;
      height: 60px;
      margin-top: 5px;
      border-radius: 50%;
      background: #18191b;
      box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
      img {
        width: 40px;
        height: auto;
      }
    }
    .child-menu-wrap {
      position: absolute;
      bottom: 104px;
      left: 0;
      width: auto;
      height: auto;
      padding: 2px 10px;
      background: rgba(255, 255, 255, 0.4);
      border-radius: 4px;
      box-shadow: inset 10px 0 6px -6px rgba(255, 255, 255, 0.4),
        inset -10px 0 6px -6px rgba(255, 255, 255, 0.4),
        inset 0 15px 6px -6px rgba(255, 255, 255, 0.4);
      display: none;
      opacity: 1;
      transition: 0.5s;
      .child-menu-one {
        padding: 5px;
        margin: 6px 0;
        color: #fff;
        overflow: hidden;
        white-space: nowrap;
        background: url("~@/assets/images/menu_item.png") no-repeat;
        background-size: 100% 100%;
        transition: 0.1s;
        img {
          margin: 0 6px;
          height: 14px;
          width: auto;
        }
        span {
          padding-right: 18px;
          font-size: 15px;
        }
        &:hover {
          color: $daihoverColor;
          transform: scale(1.05);
        }
      }
    }
  }
}
</style>
